using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Collections;

using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Drawing;
using Camalon.Drawing;
using System.ComponentModel.Design.Serialization;
using System.CodeDom;

using System.Reflection;

namespace Camalon.Drawing.Design
{
	/// <summary>
	/// Summary description for ComponentBaseDesigner.
	/// </summary>
	public class ComponentBaseDesigner:ComponentDesigner
	{
		public ComponentBaseDesigner()
		{
			//
			// TODO: Add constructor logic here
			//
		}


		IToolboxService _toolboxService;
		protected virtual IToolboxService ToolboxService
		{
			get
			{
				if( _toolboxService == null) _toolboxService = GetService(typeof(IToolboxService)) as IToolboxService;
				return _toolboxService;
			}

		}
		

		IReferenceService _referenceService;
		protected virtual IReferenceService ReferenceService
		{
			get
			{
				if( _referenceService == null) _referenceService = GetService(typeof(IReferenceService)) as IReferenceService;
				return _referenceService;
			}

		}


		IDesignerHost _designerHost;
		protected virtual IDesignerHost DesignerHost
		{
			get
			{
				if( _designerHost == null) _designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
				return _designerHost;
			}
		}

		IMenuCommandService _menuCommandService;
		protected virtual IMenuCommandService MenuCommandService
		{
			get
			{
				if( _menuCommandService == null) _menuCommandService = GetService(typeof(IMenuCommandService)) as IMenuCommandService;
				return _menuCommandService;
			}

		}

		ISelectionService _selectionService;
		protected virtual ISelectionService SelectionService
		{
			get
			{
				if( _selectionService == null) _selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
				return _selectionService;
			}
		}

		IComponentChangeService _changeService;
		protected virtual IComponentChangeService ChangeService
		{
			get
			{
				if( _changeService == null) _changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
				return _changeService;
			}
		}

		protected virtual ShapeContainerRootDesignerBase ShapeContainerRootDesigner
		{
			get
			{
				return this.RootDesigner as ShapeContainerRootDesignerBase;
			}
		}


		IRootDesigner _rootDesigner;
		protected virtual IRootDesigner RootDesigner
		{
			get
			{
				if( _rootDesigner == null && this.DesignerHost != null)
					_rootDesigner = this.DesignerHost.GetDesigner( this.DesignerHost.RootComponent) as IRootDesigner;
				
				return _rootDesigner;				
			}
		}


		IComponent _rootComponent;
		protected virtual IComponent RootComponent
		{
			get
			{
			
				if( _rootComponent == null && this.DesignerHost != null)
					_rootComponent = this.DesignerHost.RootComponent;

				return _rootComponent;

			}
		}

	}
}
